/******************************************************************************
 *      Mestrado em Cienncia da Computacao - UFMS
 *		Redes de Computadores - Prof. Dr. Ronaldo Alves Ferreira
 *		Alunos: Geraldo Landre, Marcel Tolentino, Vinicius Bueno
 *****************************************************************************/
/* tcp_in.c - tcp_in */

#include "my_socket.h"
#include "tcb.h"
#include "thread.h"

/*------------------------------------------------------------------------
 *  tcp_in - entregar um pacote de entrada TCP para o processo TCP
 *------------------------------------------------------------------------
 */
//int tcp_in(struct netif *pni, struct ep *pep)
int tcp_in(struct udp *pudp)
{
    // drop instead of blocking on thread_sendmsg
    
    TcpInSegs++;
    if (thread_countmsg(input_thread) >= TCPQLEN)
    {
        //freebuf(pep);
        free(pudp);
        return SYSERR;
    }
    thread_sendmsg(input_thread, (int)pudp);

    return OK;
}
